package cybertechcebu.task
{
	import cybertechcebu.Console;
	import cybertechcebu.FTPClient;
	import cybertechcebu.FTPCommand;
	import cybertechcebu.FTPResponse;
	import cybertechcebu.LocalFile;
	import cybertechcebu.enum.Commands;
	import cybertechcebu.enum.FileStatus;
	import cybertechcebu.enum.Responses;
	
	import mx.controls.Alert;
	import mx.core.mx_internal;
	import mx.utils.object_proxy;
	
	public class FeaturesTask extends Task
	{
		private var NO_CODE:int = 0;
		private var replyStart:Boolean = false;
		
		public function FeaturesTask(client:FTPClient)
		{
			super(client);
		}
		
		override protected function startTask():void
		{
			sendCommand(new FTPCommand(Commands.FEAT));
		}
		
		override public function handleResponse(response:FTPResponse):void
		{
			switch (response.code)
			{
				case Responses.SYSTEM_STATUS:
					if(!replyStart){
						replyStart = true;
					}else{
						dispatchTaskEnd(true);
					}
					break;
				case NO_CODE:
					client.featureString += response.str.concat(" ");
					break;
				default:
					dispatchTaskError("Unhandled response code: " + response.code);
			}
		}
	}
}
